/*
 * mox.xc
 *
 *  Created on: Jul 11, 2010
 *      Author: jmonk
 */
#include <platform.h>
#include "mox.h"
#include "mox_slave.h"
#include "mox_log.h"
#include "mox_logger.h"

#ifdef FLASHER
#include "mox_flasher.h"
#endif

#include <module_flash.h>

int main(void)
{
	streaming chan chan_mox[NUM_CORES+1];

	par {
		on stdcore[MASTER_CORE]: mox_master(chan_mox);
		//on stdcore[LOGGER_CORE]: mox_logger(chan_mox[NUM_CORES]);
		on stdcore[0]: {
			mox_slave(chan_mox[0]);
			module_start_flash();
#ifdef MOD_FUNC_0
			MOD_FUNC_0();
#endif
		}

		on stdcore[1]: {
			mox_slave(chan_mox[1]);
#ifdef MOD_FUNC_1
			MOD_FUNC_1();
#endif
		}

		on stdcore[2]: {
			mox_slave(chan_mox[2]);
#ifdef MOD_FUNC_2
			MOD_FUNC_2();
#endif
		}

		on stdcore[3]: {
			mox_slave(chan_mox[3]);
#ifdef MOD_FUNC_3
			MOD_FUNC_3();
#endif
		}
	}

	return 0;
}

void delay_us(int delay)
{
	timer tmr;
	unsigned t;
	tmr :> t;
	tmr when timerafter(t+(100*delay)) :> void;
}
